import 'package:flutter/material.dart';
import 'package:osc/common/MyTextStyle.dart';
import 'package:osc/res/dimens.dart';

class PdButton extends StatelessWidget {
  final String data;
  final Function onTap;
  final Color bg;
  final Color borderColor;
  final TextStyle textStyle;
  final double width;
  final double height;
  EdgeInsetsGeometry margin = EdgeInsets.zero;
  EdgeInsetsGeometry padding = EdgeInsets.symmetric(horizontal: Dimens.gap_view_smallest, vertical: Dimens.gap_view_small);

  PdButton({Key key, @required this.data, this.onTap, this.bg = Colors.transparent, this.borderColor = Colors.transparent, this.textStyle = MyTextStyle.BUTTON, this.width = Dimens.view_button_width_small, this.height, this.margin, this.padding}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: (){
        if(onTap != null){
          onTap();
        }
      },
      child: Container(
        width: width,
        height: height,
        margin: margin,
        padding: padding,
//        padding: EdgeInsets.symmetric(horizontal: Dimens.gap_view_smallest, vertical: Dimens.gap_view_small),
        alignment: Alignment.center,
        decoration: BoxDecoration(
          color: bg,
          border: Border.all(color: borderColor),
          borderRadius: BorderRadius.circular(Dimens.view_radius_size_smaller),
        ),
        child: Text(data, style: textStyle,),
      ),
    );
  }
}


class FocusButton extends PdButton{
  final String data;
  final Function onTap;
  FocusButton({@required this.data, this.onTap})
      :super(data: data, onTap: onTap, borderColor: Colors.green, textStyle: MyTextStyle.GREEN_BUTTON);
}
